<?php

declare(strict_types=1);

namespace app\admin\controller;

use think\facade\View; //模板引擎
use app\common\Base;
use think\facade\Request;
use think\exception\ValidateException;
use app\model\Config as ConfigMod;

/**
 * @name 系统配置
 */
class Config extends Base
{

    /**
     * @name 网站配置
     */
    public function config()
    {

        if (request()->isGet()) {
            $config = Request::param('config');
            if (isset($config)) {
                $config = $config;
            } else {
                $config = 'webinfo';
            }
            $list = ConfigMod::list($config);
            View::assign('list', $list);
            return View::fetch('config/' . $config);
        }

        if (request()->isPost()) {
            $param = Request::param();
            if (!isset($param['config'])) {
                $param['config'] = 'config';
            }
            $res = ConfigMod::saves($param);
            return getBack(0);
        }
        return View::fetch();
        
    }
}
